package com.wll.springbootminiomaster.common.util;

import com.wll.springbootminiomaster.common.constant.CodeEnums;
import lombok.Data;

@Data
public class ResponseJson {
    private String code;
    private String msg;
    private Object data;


    public ResponseJson() {

    }

    public ResponseJson(Object data, CodeEnums codeEnums) {
        this.data = data;
        this.code = codeEnums.getCode();
        this.msg = codeEnums.getMsg();
    }

    public ResponseJson(Object data, String code, String msg) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }


    public static ResponseJson success() {
        return new ResponseJson((Object)null, CodeEnums.SUCCESS_CODE);
    }

    public static ResponseJson success(Object data) {
        return new ResponseJson(data, CodeEnums.SUCCESS_CODE);
    }



    public static ResponseJson error() {
        return new ResponseJson((Object)null, CodeEnums.ERROR_CODE);
    }

    public static ResponseJson error(Object data) {
        return new ResponseJson(data, CodeEnums.ERROR_CODE);
    }



    public static ResponseJson msg(String msg) {
        return new ResponseJson((Object)null, CodeEnums.ERROR_MSG.getCode(), msg);
    }

    public static ResponseJson notLogin() {
        return new ResponseJson((Object)null, CodeEnums.NOT_LOGIN);
    }

    public static ResponseJson noResult() {
        return new ResponseJson((Object)null, CodeEnums.NO_RESULT);
    }

    public static ResponseJson build(Object data, String code, String msg) {
        return new ResponseJson(data, code, msg);
    }

    public static ResponseJson build(Object data, CodeEnums codeEnums) {
        return new ResponseJson(data, codeEnums.getCode(), codeEnums.getMsg());
    }

    public static ResponseJson build(CodeEnums codeEnums) {
        return new ResponseJson(null, codeEnums.getCode(), codeEnums.getMsg());
    }

    public static ResponseJson build(String code, String msg) {
        return new ResponseJson(null, code, msg);
    }

}
